package edu.hrbu.spring.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author 徐登宇
 */
public class UpdateInvocarionHandler implements InvocationHandler {

    private final Object target;

    public UpdateInvocarionHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("【目标方法】执行之前");

        // 执行目标方法
        int line = (int) method.invoke(this.target, args);

        System.out.println("【目标方法】执行之后");

        return line;
    }
}
